<?php

class Session_Dao{
	
	function salting($session){
		
		$salting1 = "si";
		$salting2 = "ftif";
		$username = htmlentities($session->username);
		$password = strrev(htmlentities($session->password));
		if(((strlen($password))%2)==1){
			$password = $salting1.$password.$salting2;
		}else{
			$password = $salting2.$password.$salting1;
		};
		$password = md5($password);
		
		$session->username = $username;
		$session->password = $password;
		
		return $session;
		
	}
	
	function login(Session $session){
		
		/* session_register("Id_pengguna");
		session_register("username");
		session_register("password");
		session_register("authority"); */
		
		$_SESSION['Id_pengguna'] = $session->Id_pengguna;
		$_SESSION['username']    = $session->username;
		$_SESSION['password']    = $session->password;
		$_SESSION['authority']   = $session->authority;
	
		return $session;
	}
	
	function logout(){
		
		unset($_SESSION['Id_pengguna']);
		unset($_SESSION['username']);
		unset($_SESSION['password']);
		unset($_SESSION['authority']);
		
	}
	
}

class Session{

	var $Id_pengguna = '';
	var $username    = '';
	var $password    = '';
	var $authority   = '';
	
}